package ua.amsoft.brelok.chart;

import ua.amsoft.brelok.dto.Range;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RemoteViews.RemoteView;

/**
 * Custom view for pie chart
 * 
 * @author Tair Mustafaiev
 */
@RemoteView
public class BrelokPieChartView extends View {
    
    private final BrelokPieChartDrawable drawable;
    
    private final Range chart;
    
    /**
     * Constructor
     * 
     * @param context - {@link Context}
     * @param chartObject - chart objects with values to be drawed
     */
    public BrelokPieChartView(final Context context, final Range chartObject) {
        super(context);
        this.chart = chartObject;
        this.drawable = new BrelokPieChartDrawable(this.chart);
    }
    
    /**
     * View Constructor
     * 
     * @param context - {@link Context}
     * @param attributeSet - {@link AttributeSet}
     */
    public BrelokPieChartView(final Context context, final AttributeSet attributeSet) {
        super(context, attributeSet);
        this.chart = new Range();
        this.drawable = new BrelokPieChartDrawable(this.chart);
    }
    
    /**
     * View Constructor
     * 
     * @param context - Context
     * @param attributeSet - {@link AttributeSet}
     * @param defStyle - style
     */
    public BrelokPieChartView(final Context context, final AttributeSet attributeSet,
            final int defStyle) {
        super(context, attributeSet, defStyle);
        this.chart = new Range();
        this.drawable = new BrelokPieChartDrawable(this.chart);
    }
    
    @Override
    protected void onDraw(final Canvas canvas) {
        this.drawable.draw(canvas);
    }
    
}
